import type { IContentConfig } from "@/components/PageContent/index.vue";
import { exportUser, getList } from "@/api/lxr/rule/index";

const contentConfig: IContentConfig = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  indexAction: function (data) {
    console.log("index", data);
    return new Promise(async (resolve, reject) => {
      // setTimeout(() => {
      //   resolve({
      //     code: "00000",
      //     data: {
      //       list: [
      //         {
      //           id: 2,
      //           username: "admin",
      //           nickname: "系统管理员",
      //           mobile: "17621210366",
      //           genderLabel: "男",
      //           avatar:
      //             "https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
      //           email: null,
      //           status: 1,
      //           deptName: "有来技术",
      //           roleNames: "系统管理员",
      //           createTime: "2019-10-10",
      //         },
      //         {
      //           id: 3,
      //           username: "test",
      //           nickname: "测试小用户",
      //           mobile: "17621210366",
      //           genderLabel: "男",
      //           avatar:
      //             "https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
      //           email: null,
      //           status: 1,
      //           deptName: "测试部门",
      //           roleNames: "访问游客",
      //           createTime: "2021-06-05",
      //         },
      //       ],
      //       total: 2,
      //     },
      //     msg: "一切ok",
      //   });
      // }, 800);
      let params = <PageQuery>{
        // pageNum: 0,
        // pageSize: 10,
        ...data,
      };
      const res = await getList(params);
      resolve(res);
    });
  },
  deleteAction: function (id) {
    console.log("delete", id);
    return new Promise((resolve, reject) => {
      resolve({
        code: "00000",
        data: null,
        msg: "删除成功",
      });
    });
  },
  exportAction: function (queryParams) {
    // 导出Excel文件
    return exportUser(queryParams as any);
  },
  pk: "id",
  toolbar: [
    "refresh",
    "add",
    "delete",
    "export",
    {
      name: "import",
      icon: "upload",
      text: "导入",
      auth: "import",
    },
  ],
  cols: [
    { type: "selection", width: 50, align: "center" },
    {
      label: "关联场景名称",
      align: "center",
      prop: "sceneId",
      width: 130,
      templet: "custom",
      slotName: "sceneId",
    },
    { label: "规则名称", align: "center", prop: "ruleName", width: 130 },
    { label: "风险属性", align: "center", prop: "riskField", width: 120 },
    { label: "规则类型", align: "center", prop: "ruleType", width: 100 },
    { label: "规则表达式", align: "center", prop: "totalExpress", width: 120 },
    {
      label: "状态",
      align: "center",
      prop: "status",
      templet: "custom",
      slotName: "status",
    },
    {
      label: "操作",
      fixed: "right",
      width: 220,
      templet: "tool",
      operat: [
        {
          name: "reset_pwd",
          auth: "password:reset",
          icon: "refresh-left",
          text: "重置密码",
        },
        "edit",
        "delete",
      ],
    },
  ],
};

export default contentConfig;
